package com.itboye.zhujia.me.key;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.Intent;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.zhujia.R;
import com.itboye.zhujia.adapter.key.ItemUserManAdapter;
import com.itboye.zhujia.base.BaseActivity;
import com.itboye.zhujia.custom.SelectPicPopupWindow;
import com.itboye.zhujia.custom.SelectPicPopupWindowUser;
import com.itboye.zhujia.custom.XListView;
/**
 * 用户管理
 *
 */
public class ActivityUserManagement extends BaseActivity {
	ImageView close_icon;//返回图片
	TextView add_shap_title_tv;//标题
	
	XListView xlistview;
	
	List<Map<String, Object>> list;
	
	ItemUserManAdapter adapter;
	
	/**
	 * 自定义的弹出框类
	 */
	SelectPicPopupWindowUser menuWindow;

	@Override
	public int initView() {
		return 0;
	}

	@Override
	public void onMyCreate() {
		setContentView(R.layout.activity_user_management);
		
		add_shap_title_tv.setText("用户管理");
		
		adapter=new ItemUserManAdapter(ActivityUserManagement.this, add());
		xlistview.setAdapter(adapter);
		
		/**
		 * listview点击事件
		 */
		xlistview.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				//实例化SelectPicPopupWindow
				menuWindow = new SelectPicPopupWindowUser(ActivityUserManagement.this, itemsOnClick);
				//显示窗口
				menuWindow.showAtLocation(ActivityUserManagement.this.findViewById(R.id.user_main),
						Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0); //设置layout在PopupWindow中显示的位置
				
			}
		});
		
	}
	
	/**
	 * 为弹出窗口实现监听类
	 */
    private OnClickListener  itemsOnClick = new OnClickListener(){

		public void onClick(View v) {
			menuWindow.dismiss();
			switch (v.getId()) {
			case R.id.user_pop_delete://删除
				break;
			case R.id.user_pop_frozen://冻结
				break;
			case R.id.user_pop_relieve://解除冻结
				break;
			case R.id.user_pop_cancel://取消
				break;
			default:
				break;
			}
		}
    };
	/**
	 * 静态数据源
	 * @return
	 */
	public List<Map<String, Object>> add(){
		list=new ArrayList<Map<String, Object>>();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("img", R.drawable.ic_launcher);
		map.put("name", "15238566666");
		map.put("state", "永久钥匙");
		map.put("time", "正常状态");
		list.add(map);
		
		return list;
	}
}
